#!/user/bin/env python3
# -*- coding: utf-8 -*-
"""
--------------------------------------
    Author:     JiChao_Song
    Date  :     2022/1/5 15:59
    Desc  :
--------------------------------------
"""
from apps import AbstractBaseModel
from django.db import models

from common.enums.project_enums import ProjectStatusEnums


class Project(AbstractBaseModel):
    """项目表"""
    projectName = models.CharField(max_length = 255, help_text = '项目名称')
    projectIcon = models.CharField(max_length = 255, help_text = '项目图标', null = True)
    projectDesc = models.CharField(max_length = 2000, help_text = '项目描述', null = True)
    projectStatus = models.IntegerField(default = ProjectStatusEnums.PLANING.key, help_text = '项目状态')
    beginTime = models.BigIntegerField(null = True, blank = True, help_text = '开始时间')
    endTime = models.BigIntegerField(null = True, blank = True, help_text = '结束时间')
    closedBy = models.CharField(max_length = 255, null = True, help_text = '由谁关闭')
    closedTime = models.BigIntegerField(null = True, blank = True, help_text = '关闭时间')
    projectLeaderId = models.IntegerField(null = True, help_text = '项目负责人id')
    projectLeaderName = models.CharField(max_length = 255, null = True, help_text = '项目负责人名称')
    persons = models.CharField(max_length = 2000, null = True, help_text = '项目成员ids', default = '[]')

    class Meta:
        verbose_name = 'Project'
        verbose_name_plural = verbose_name
        db_table = 'tProject'
        unique_together = ('projectName', 'deleted', 'id')
        ordering = ['-createTime']


class ProjectPerson(AbstractBaseModel):
    """项目成员表"""
    projectId = models.IntegerField(help_text = '项目id')
    personId = models.IntegerField(help_text = '成员id')

    class Meta:
        verbose_name = 'ProjectPerson'
        verbose_name_plural = verbose_name
        db_table = 'tProjectPerson'
        ordering = ['-createTime']
